<template>
  <!--  -->
  <div class="heritage-industry">
    <!-- 地图容器 -->
    <div id="container" class="container">
      <div class="map-buttons">
        <el-button
          type="text"
          size="mini"
          @click="addRoadLayer"
          v-show="!roadNetwork"
          class="map-btn map-element"
          >{{ lang === "zh_cn" ? "打开路网" : "Open road" }}</el-button
        >
        <el-button
          type="text"
          size="mini"
          @click="removeRoadLayer"
          v-show="roadNetwork"
          class="map-btn map-element"
          >{{ lang === "zh_cn" ? "关闭路网" : "Close road" }}</el-button
        >

        <el-button
          type="text"
          size="mini"
          @click="addSatellite"
          v-show="isOrdMap"
          class="map-btn map-element"
          >{{ lang === "zh_cn" ? "卫星地图" : "Satellite map" }}</el-button
        >
        <el-button
          type="text"
          size="mini"
          @click="removeSatellite"
          v-show="!isOrdMap"
          class="map-btn map-element"
          >{{ lang === "zh_cn" ? "普通地图" : "General map" }}</el-button
        >

        <el-button
          type="text"
          size="mini"
          @click="resetMap"
          class="map-btn map-element"
          >{{ lang === "zh_cn" ? "复位" : "Reset" }}</el-button
        >
      </div>

      <!-- 几何查询弹框 -->
    </div>
  </div>
</template>

<script
  type="text/javascript"
  src="https://webapi.amap.com/maps?v=1.4.15&key=2eccb47b400c8ab58f2dc596dbfe9d53&plugin=AMap.MouseTool,AMap.DistrictSearch"
></script>
<script>
import { mapState, mapMutations } from "vuex";
export default {
  name: "HeritageIndustry",

  data() {
    return {
      map: "",
      district: null,
      polygons: [],
      marker: null, //点位
      // 弹框内容
      title: "",
      content: [],
      infoWindow: null,

      dataList: null, // 数据
      isOrdMap: true, //判断是卫星图还是普通图，普通图为true
      satellite: null, //用来存储卫星地图影像
      roadNetwork: false, //是否具有路网，默认没有
      roadNetLayer: null, //用来存储路网

      // 带有输入建议的搜索框
      restaurants: [],
      searchIndustry: "",
      searchObj: null,
      markers: [],

      // 几何查询
      geometrySearchType: "circle",
      geometryBox: false, //几何查询面板隐藏展示
      mouseTool: null,
      overlays: [], //绘制好的覆盖物
      geometrySearchRes: [], //几何查询结果
      issearchRes: true, //查询结果图标显示隐藏

      // 类型查询
      options: [
        {
          type: "test",
          name: "test",
        },
      ],
      typeSelect: "test",

      list: [],
  cityData: [
        {
          Mcity: "四川省",
          city: "成都市",
          address: "成都市",
          jing: 104.066541,
          wei: 30.572269,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "锦江区",
          jing: 104.080989,
          wei: 30.657689,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "青羊区",
          jing: 104.062499,
          wei: 30.674406,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "金牛区",
          jing: 104.117422,
          wei: 30.763102,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "武侯区",
          jing: 104.04339,
          wei: 30.641982,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "成华区",
          jing: 104.101255,
          wei: 30.660122,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "龙泉驿区",
          jing: 104.274632,
          wei: 30.556507,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "青白江区",
          jing: 104.250877,
          wei: 30.878681,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "新都区",
          jing: 104.158705,
          wei: 30.823499,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "温江区",
          jing: 103.837104,
          wei: 30.69046,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "双流区",
          jing: 103.951908,
          wei: 30.333027,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "郫都区",
          jing: 103.901092,
          wei: 30.795854,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "金堂县",
          jing: 104.412005,
          wei: 30.862017,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "郫县",
          jing: 103.886629,
          wei: 30.808481,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "大邑县",
          jing: 103.511875,
          wei: 30.572269,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "蒲江县",
          jing: 103.506498,
          wei: 30.196789,
        },
        {
          Mcity: "四川省",
          city: "成都市",
          address: "新津县",
          jing: 103.811345,
          wei: 30.410222,
        },
        {
          Mcity: "四川省",
          city: "都江堰市",
          address: "都江堰市",
          jing: 103.650219,
          wei: 30.975943,
        },
        {
          Mcity: "四川省",
          city: "彭州市",
          address: "彭州市",
          jing: 103.958013,
          wei: 30.990165,
        },
        {
          Mcity: "四川省",
          city: "邛崃市",
          address: "邛崃市",
          jing: 103.464156,
          wei: 30.410275,
        },
        {
          Mcity: "四川省",
          city: "崇州市",
          address: "崇州市",
          jing: 103.673001,
          wei: 30.630122,
        },
        {
          Mcity: "四川省",
          city: "简阳市",
          address: "简阳市",
          jing: 104.546773,
          wei: 30.410754,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "自贡市",
          jing: 104.778442,
          wei: 29.33903,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "自流井区",
          jing: 104.777191,
          wei: 29.33743,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "贡井区",
          jing: 104.715117,
          wei: 29.345546,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "大安区",
          jing: 104.773968,
          wei: 29.363634,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "沿滩区",
          jing: 104.874073,
          wei: 29.272581,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "荣县",
          jing: 104.417388,
          wei: 29.44541,
        },
        {
          Mcity: "四川省",
          city: "自贡市",
          address: "富顺县",
          jing: 104.975048,
          wei: 29.18143,
        },
        {
          Mcity: "四川省",
          city: "攀枝花市",
          address: "攀枝花市",
          jing: 101.718637,
          wei: 26.582347,
        },
        {
          Mcity: "四川省",
          city: "攀枝花市",
          address: "仁和区",
          jing: 101.738528,
          wei: 26.497765,
        },
        {
          Mcity: "四川省",
          city: "攀枝花市",
          address: "米易县",
          jing: 102.110339,
          wei: 26.890689,
        },
        {
          Mcity: "四川省",
          city: "攀枝花市",
          address: "盐边县",
          jing: 101.855071,
          wei: 26.683213,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "泸州市",
          jing: 105.442258,
          wei: 28.87181,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "江阳区",
          jing: 105.435009,
          wei: 28.878818,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "纳溪区",
          jing: 105.371151,
          wei: 28.773428,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "龙马潭区",
          jing: 105.437765,
          wei: 28.913221,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "泸县",
          jing: 105.381893,
          wei: 29.151534,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "合江县",
          jing: 105.831067,
          wei: 28.811203,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "叙永县",
          jing: 105.444765,
          wei: 28.155801,
        },
        {
          Mcity: "四川省",
          city: "泸州市",
          address: "古蔺县",
          jing: 105.812602,
          wei: 28.038802,
        },
        {
          Mcity: "四川省",
          city: "德阳市",
          address: "德阳市",
          jing: 104.397894,
          wei: 31.126855,
        },
        {
          Mcity: "四川省",
          city: "德阳市",
          address: "旌阳区",
          jing: 104.416943,
          wei: 31.142498,
        },
        {
          Mcity: "四川省",
          city: "德阳市",
          address: "罗江区",
          jing: 104.510249,
          wei: 31.317045,
        },
        {
          Mcity: "四川省",
          city: "德阳市",
          address: "中江县",
          jing: 104.678749,
          wei: 31.033051,
        },
        {
          Mcity: "四川省",
          city: "德阳市",
          address: "罗江县",
          jing: 104.510249,
          wei: 31.317045,
        },
        {
          Mcity: "四川省",
          city: "广汉市",
          address: "广汉市",
          jing: 104.282331,
          wei: 30.976165,
        },
        {
          Mcity: "四川省",
          city: "什邡市",
          address: "什邡市",
          jing: 104.167501,
          wei: 31.12678,
        },
        {
          Mcity: "四川省",
          city: "绵竹市",
          address: "绵竹市",
          jing: 104.22075,
          wei: 31.338077,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "绵阳市",
          jing: 104.679114,
          wei: 31.46745,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "涪城区",
          jing: 104.750215,
          wei: 31.47083,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "游仙区",
          jing: 104.766393,
          wei: 31.473779,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "安州区",
          jing: 104.567187,
          wei: 31.534886,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "三台县",
          jing: 105.094586,
          wei: 31.095979,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "盐亭县",
          jing: 105.389453,
          wei: 31.208363,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "梓潼县",
          jing: 105.170845,
          wei: 31.642718,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "北川羌族自治县",
          jing: 104.46797,
          wei: 31.617203,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "北川县",
          jing: 104.46797,
          wei: 31.617203,
        },
        {
          Mcity: "四川省",
          city: "绵阳市",
          address: "平武县",
          jing: 104.555583,
          wei: 32.409675,
        },
        {
          Mcity: "四川省",
          city: "江油市",
          address: "江油市",
          jing: 104.745877,
          wei: 31.778025,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "广元市",
          jing: 105.843357,
          wei: 32.435435,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "利州区",
          jing: 105.845218,
          wei: 32.433898,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "昭化区",
          jing: 105.964121,
          wei: 32.322788,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "朝天区",
          jing: 105.890445,
          wei: 32.643982,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "旺苍县",
          jing: 106.289905,
          wei: 32.228917,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "青川县",
          jing: 105.238842,
          wei: 32.575485,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "剑阁县",
          jing: 105.524766,
          wei: 32.287723,
        },
        {
          Mcity: "四川省",
          city: "广元市",
          address: "苍溪县",
          jing: 105.934801,
          wei: 31.732432,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "遂宁市",
          jing: 105.592898,
          wei: 30.532847,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "船山区",
          jing: 105.568297,
          wei: 30.525475,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "安居区",
          jing: 105.456342,
          wei: 30.355379,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "蓬溪县",
          jing: 105.70757,
          wei: 30.757575,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "射洪县",
          jing: 105.388405,
          wei: 30.870986,
        },
        {
          Mcity: "四川省",
          city: "遂宁市",
          address: "大英县",
          jing: 105.236904,
          wei: 30.594337,
        },
        {
          Mcity: "四川省",
          city: "内江市",
          address: "内江市",
          jing: 105.058433,
          wei: 29.580228,
        },
        {
          Mcity: "四川省",
          city: "内江市",
          address: "东兴区",
          jing: 105.07549,
          wei: 29.592756,
        },
        {
          Mcity: "四川省",
          city: "内江市",
          address: "威远县",
          jing: 104.668879,
          wei: 29.52744,
        },
        {
          Mcity: "四川省",
          city: "内江市",
          address: "资中县",
          jing: 104.851944,
          wei: 29.764059,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "乐山市",
          jing: 103.765568,
          wei: 29.552106,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "市中区",
          jing: 103.76133,
          wei: 29.555375,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "沙湾区",
          jing: 103.549991,
          wei: 29.413091,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "五通桥区",
          jing: 103.818009,
          wei: 29.406932,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "金口河区",
          jing: 103.078621,
          wei: 29.244345,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "犍为县",
          jing: 103.949326,
          wei: 29.208171,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "井研县",
          jing: 104.069726,
          wei: 29.651287,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "夹江县",
          jing: 103.571657,
          wei: 29.73763,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "沐川县",
          jing: 103.902335,
          wei: 28.956647,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "峨边彝族自治县",
          jing: 103.262048,
          wei: 29.230425,
        },
        {
          Mcity: "四川省",
          city: "乐山市",
          address: "马边彝族自治县",
          jing: 103.546348,
          wei: 28.835521,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "峨眉山市",
          jing: 103.484504,
          wei: 29.601199,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "天城区",
          jing: 103.89528,
          wei: 30.798276,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "南充市",
          jing: 106.110698,
          wei: 30.837793,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "顺庆区",
          jing: 106.092399,
          wei: 30.796486,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "高坪区",
          jing: 106.118808,
          wei: 30.781623,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "嘉陵区",
          jing: 106.071793,
          wei: 30.758748,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "南部县",
          jing: 106.036584,
          wei: 31.347467,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "营山县",
          jing: 106.56542,
          wei: 31.076461,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "蓬安县",
          jing: 106.412151,
          wei: 31.029097,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "仪陇县",
          jing: 106.303042,
          wei: 31.271562,
        },
        {
          Mcity: "四川省",
          city: "峨眉山市",
          address: "西充县",
          jing: 105.900878,
          wei: 30.995669,
        },
        {
          Mcity: "四川省",
          city: "阆中市",
          address: "阆中市",
          jing: 106.005047,
          wei: 31.558357,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "眉山市",
          jing: 103.848538,
          wei: 30.075439,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "东坡区",
          jing: 103.831752,
          wei: 30.042345,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "彭山区",
          jing: 103.87295,
          wei: 30.193056,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "仁寿县",
          jing: 104.134082,
          wei: 29.99563,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "洪雅县",
          jing: 103.372863,
          wei: 29.90489,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "丹棱县",
          jing: 103.512733,
          wei: 30.014448,
        },
        {
          Mcity: "四川省",
          city: "眉山市",
          address: "青神县",
          jing: 103.846688,
          wei: 29.831358,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "宜宾市",
          jing: 104.643215,
          wei: 28.751768,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "翠屏区",
          jing: 104.644534,
          wei: 28.758563,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "宜宾县",
          jing: 104.533213,
          wei: 28.690045,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "长宁县",
          jing: 104.914158,
          wei: 28.577349,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "高县",
          jing: 104.518187,
          wei: 28.435036,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "珙县",
          jing: 104.713083,
          wei: 28.443674,
        },
        {
          Mcity: "四川省",
          city: "宜宾市",
          address: "屏山县",
          jing: 104.156008,
          wei: 28.708446,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "广安市",
          jing: 106.633212,
          wei: 30.455961,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "广安区",
          jing: 106.641608,
          wei: 30.474003,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "前锋区",
          jing: 106.893277,
          wei: 30.4963,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "岳池县",
          jing: 106.440114,
          wei: 30.537863,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "武胜县",
          jing: 106.295764,
          wei: 30.348772,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "邻水县",
          jing: 106.93038,
          wei: 30.334769,
        },
        {
          Mcity: "四川省",
          city: "广安市",
          address: "华蓥市",
          jing: 106.783088,
          wei: 30.390435,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "达州市",
          jing: 107.468023,
          wei: 31.209571,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "通川区",
          jing: 107.504517,
          wei: 31.214724,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "达川区",
          jing: 107.511845,
          wei: 31.196118,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "宣汉县",
          jing: 107.727191,
          wei: 31.353835,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "开江县",
          jing: 107.868736,
          wei: 31.082987,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "大竹县",
          jing: 107.204744,
          wei: 30.736266,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "渠县",
          jing: 106.972996,
          wei: 30.836659,
        },
        {
          Mcity: "四川省",
          city: "达州市",
          address: "万源市",
          jing: 108.034657,
          wei: 32.081631,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "雅安市",
          jing: 103.013261,
          wei: 29.980537,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "雨城区",
          jing: 103.033083,
          wei: 30.005447,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "名山区",
          jing: 103.109185,
          wei: 30.069954,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "荥经县",
          jing: 102.846738,
          wei: 29.792931,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "汉源县",
          jing: 102.645453,
          wei: 29.347187,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "石棉县",
          jing: 102.359462,
          wei: 29.227874,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "天全县",
          jing: 102.758317,
          wei: 30.066713,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "芦山县",
          jing: 102.92826,
          wei: 30.144084,
        },
        {
          Mcity: "四川省",
          city: "雅安市",
          address: "宝兴县",
          jing: 102.814531,
          wei: 30.368126,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "巴中市",
          jing: 106.747477,
          wei: 31.867903,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "巴州区",
          jing: 106.768878,
          wei: 31.851478,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "恩阳区",
          jing: 106.655347,
          wei: 31.786691,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "通江县",
          jing: 107.245033,
          wei: 31.911705,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "南江县",
          jing: 106.828697,
          wei: 32.346589,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "平昌县",
          jing: 107.104008,
          wei: 31.560874,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "资阳市",
          jing: 104.627636,
          wei: 30.128901,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "雁江区",
          jing: 104.677096,
          wei: 30.10821,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "安岳县",
          jing: 105.335613,
          wei: 30.097246,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "乐至县",
          jing: 105.019916,
          wei: 30.275487,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "宜宾地区",
          jing: 104.643215,
          wei: 28.751768,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "南充地区",
          jing: 106.110698,
          wei: 30.837793,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "南充县",
          jing: 106.110698,
          wei: 30.837793,
        },
        {
          Mcity: "四川省",
          city: "巴中市",
          address: "达川地区",
          jing: 107.511845,
          wei: 31.196118,
        },
        {
          Mcity: "四川省",
          city: "达川市",
          address: "达川市",
          jing: 107.511845,
          wei: 31.196118,
        },
        {
          Mcity: "四川省",
          city: "达川市",
          address: "巴中县",
          jing: 106.747477,
          wei: 31.867903,
        },
        {
          Mcity: "四川省",
          city: "达川市",
          address: "白沙工农区",
          jing: 104.160392,
          wei: 30.469654,
        },
        {
          Mcity: "四川省",
          city: "达川市",
          address: "雅安地区",
          jing: 103.013261,
          wei: 29.980537,
        },
        {
          Mcity: "四川省",
          city: "达川市",
          address: "阿坝藏族羌族自治州",
          jing: 102.224653,
          wei: 31.899413,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "马尔康市",
          jing: 102.206504,
          wei: 31.905813,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "马尔康区",
          jing: 102.206504,
          wei: 31.905813,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "汶川县",
          jing: 103.590387,
          wei: 31.476822,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "理县",
          jing: 103.166853,
          wei: 31.436473,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "茂县",
          jing: 103.853522,
          wei: 31.681154,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "松潘县",
          jing: 103.604698,
          wei: 32.655325,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "九寨沟县",
          jing: 104.243841,
          wei: 33.252056,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "金川县",
          jing: 102.063829,
          wei: 31.476277,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "小金县",
          jing: 102.364373,
          wei: 30.999031,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "黑水县",
          jing: 102.990108,
          wei: 32.061895,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "壤塘县",
          jing: 100.978526,
          wei: 32.265796,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "阿坝县",
          jing: 101.706655,
          wei: 32.902459,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "若尔盖县",
          jing: 102.961798,
          wei: 33.575892,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "红原县",
          jing: 102.544405,
          wei: 32.790891,
        },
        {
          Mcity: "四川省",
          city: "马尔康市",
          address: "甘孜藏族自治州",
          jing: 101.96231,
          wei: 30.04952,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "康定市",
          jing: 101.957146,
          wei: 29.998436,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "泸定县",
          jing: 102.234618,
          wei: 29.91416,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "丹巴县",
          jing: 101.890358,
          wei: 30.878577,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "九龙县",
          jing: 101.507294,
          wei: 29.000348,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "雅江县",
          jing: 101.014425,
          wei: 30.031533,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "道孚县",
          jing: 101.125237,
          wei: 30.979545,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "炉霍县",
          jing: 100.676372,
          wei: 31.39179,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "甘孜县",
          jing: 99.992671,
          wei: 31.622934,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "新龙县",
          jing: 100.311369,
          wei: 30.939169,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "德格县",
          jing: 98.580915,
          wei: 31.806118,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "白玉县",
          jing: 98.824182,
          wei: 31.209913,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "石渠县",
          jing: 98.1029,
          wei: 32.97896,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "色达县",
          jing: 100.332743,
          wei: 32.268129,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "理塘县",
          jing: 100.269818,
          wei: 29.996049,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "巴塘县",
          jing: 99.110712,
          wei: 30.004677,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "乡城县",
          jing: 99.798435,
          wei: 28.931172,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "稻城县",
          jing: 100.298403,
          wei: 29.037007,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "得荣县",
          jing: 99.286335,
          wei: 28.713037,
        },
        {
          Mcity: "四川省",
          city: "康定市",
          address: "凉山彝族自治州",
          jing: 102.267335,
          wei: 27.88161,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "西昌市",
          jing: 102.264449,
          wei: 27.894504,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "木里藏族自治县",
          jing: 101.280206,
          wei: 27.928835,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "盐源县",
          jing: 101.509188,
          wei: 27.422645,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "德昌县",
          jing: 102.17567,
          wei: 27.402839,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "会理县",
          jing: 102.244683,
          wei: 26.655026,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "会东县",
          jing: 102.577961,
          wei: 26.634669,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "宁南县",
          jing: 102.759634,
          wei: 27.066384,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "普格县",
          jing: 102.540901,
          wei: 27.376413,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "布拖县",
          jing: 102.811631,
          wei: 27.706192,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "金阳县",
          jing: 103.248772,
          wei: 27.696861,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "昭觉县",
          jing: 102.842611,
          wei: 28.014088,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "喜德县",
          jing: 102.412518,
          wei: 28.306726,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "冕宁县",
          jing: 102.17701,
          wei: 28.549657,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "越西县",
          jing: 102.50768,
          wei: 28.639801,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "甘洛县",
          jing: 102.771749,
          wei: 28.966069,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "美姑县",
          jing: 103.13218,
          wei: 28.32864,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "雷波县",
          jing: 103.571696,
          wei: 28.262683,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "广安地区",
          jing: 106.633212,
          wei: 30.455961,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "巴中地区",
          jing: 106.747477,
          wei: 31.867903,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "眉山地区",
          jing: 103.848538,
          wei: 30.075439,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "眉山县",
          jing: 103.848538,
          wei: 30.075439,
        },
        {
          Mcity: "四川省",
          city: "西昌市",
          address: "资阳地区",
          jing: 104.627636,
          wei: 30.128901,
        },
      ],
    };
  },

  computed: {
    ...mapState(["lang", "dataArr"]),
  },
  async created() {
    this.dataList = this.dataArr;

    this.getAllType(); //初始化下拉菜单
    this.changeinstryType("one");
  },

  mounted() {
    this.initMap(); //初始化地图
    this.drawHotMap();
    this.mouseTool = new AMap.MouseTool(this.map);
    // this.addMarker()
  },

  methods: {
    ...mapMutations(["changeinstryType"]),

    initMap() {
      //初始化地图
      this.map = new AMap.Map("container", {
        resizeEnable: true,
        zoom: 6, //级别
        zooms: [1, 18],
        center: [104.07,30.57], //中心点坐标
        viewMode: "3D", //使用3D视图
        lang: this.lang,
        mapStyle: "amap://styles/normal",
        infoWindow: null,
      });
    },

    // 裁剪边界

    drawHotMap() {
      this.$message({
        message: "热力图绘制中，初次加载可能用时较长",
      });

      for (let i = 0; i < this.cityData.length; i++) {
        this.list.push({
          coordinate: [this.cityData[i].jing, this.cityData[i].wei],
          count: this.cityData[i],
        });
      }

      this.layer = new Loca.HeatmapLayer({
        map: this.map,
        // fitView: true,
      });
      console.log("this.list", this.list);
      this.layer.setData(this.list, {
        lnglat: "coordinate",
        value: "count",
      });

      //  radius为热力半径，由于初期数据未录入，故设置的较大，默认为16，后续数据全部录入后再进行修改。
      this.layer.setOptions({
        style: {
          radius: 35,
          color: {
            0.5: "#2c7bb6",
            0.65: "#abd9e9",
            0.7: "#ffffbf",
            0.9: "#fde468",
            1.0: "#d7191c",
          },
        },
      });

      this.layer.render();
    },

    // 添加点集
    addMarker() {
      for (let i = 0; i < this.cityData.length; i++) {
        // 循环点坐标
        // 注意这里一定得用 let
        let marker = new AMap.Marker({
          // 自定义图标
          icon: new AMap.Icon({
            image:
              "https://mp-b0bd9cd4-ad06-4cf0-b1a3-ea2e46e926bc.cdn.bspapp.com/cloudstorage/7bea69ff-bb2b-4667-8d33-eab9f0b9ed2b.png",
            size: new AMap.Size(45, 45),
            imageSize: new AMap.Size(45, 45),
          }),
          map: this.map,
          position: [this.cityData[i].jing,this.cityData[i].wei],
          extData: this.cityData[i],
        });

        this.markers.push(marker);

        AMap.event.addListener(marker, "click", () => {
          // this.nowMarker = marker;

          // console.log(this.infoWindow);
          this.title = this.cityData[i].address;

          (this.content = [
            "火灾点ID：" + this.cityData[i].jing,


          ]),
            (this.infoWindow = new AMap.InfoWindow({
              isCustom: true, //使用自定义窗体
              // content: '  <div style="background-color:white">111</div>',
              content: this.createInfoWindow(
                this.title,
                this.content.join("<br/>")
              ),
              offset: new AMap.Pixel(16, -45),
            }));
          this.infoWindow.open(this.map, marker.getPosition());
          // console.log(marker.getPosition());
        });
      }
      this.map.setFitView()
    },

    //渲染弹框
    createInfoWindow(title, content) {
      // console.log("11111111");
      var info = document.createElement("div");
      info.className = "custom-info input-card content-window-card";

      //可以通过下面的方式修改自定义窗体的宽高
      //info.style.width = "400px";
      // 定义顶部标题
      var top = document.createElement("div");
      var titleD = document.createElement("div");
      var closeX = document.createElement("img");
      top.className = "info-top";
      titleD.innerHTML = title;
      closeX.src = "https://webapi.amap.com/images/close2.gif";
      closeX.onclick = this.closeInfoWindow;

      top.appendChild(titleD);
      top.appendChild(closeX);
      info.appendChild(top);

      // 定义中部内容
      var middle = document.createElement("div");
      middle.className = "info-middle";
      middle.style.backgroundColor = "white";
      middle.innerHTML = content;
      info.appendChild(middle);

      // 定义底部内容
      var bottom = document.createElement("div");
      bottom.className = "info-bottom";
      bottom.style.position = "relative";
      bottom.style.top = "0px";
      bottom.style.margin = "0 auto";
      var sharp = document.createElement("img");
      sharp.src = "https://webapi.amap.com/images/sharp.png";
      bottom.appendChild(sharp);
      info.appendChild(bottom);
      return info;
    },

    // 关闭弹框
    closeInfoWindow() {
      this.map.clearInfoWindow();
      this.searchIndustry = null;
    },

    // 打开卫星地图
    addSatellite() {
      // console.log(111);
      this.isOrdMap = !this.isOrdMap;
      this.satellite = new AMap.TileLayer.Satellite();
      this.map.add(this.satellite);
    },

    // 关闭卫星地图
    removeSatellite() {
      this.isOrdMap = !this.isOrdMap;
      this.map.remove(this.satellite);
    },

    // 打开路网
    addRoadLayer() {
      this.roadNetwork = !this.roadNetwork;
      this.roadNetLayer = new AMap.TileLayer.RoadNet();
      this.map.add(this.roadNetLayer);
    },

    // 关闭路网
    removeRoadLayer() {
      this.roadNetwork = !this.roadNetwork;
      this.map.remove(this.roadNetLayer);
    },
    // 输入建议start
    handleSelect(item) {
      console.log(item);
      this.searchObj = item;
      console.log(this.searchIndustry);
    },

    querySearch(queryString, cb) {
      var restaurants = this.restaurants;
      var results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    createFilter(queryString) {
      return (restaurants) => {
        return (
          restaurants.name.toLowerCase().indexOf(queryString.toLowerCase()) ===
          0
        );
      };
    },

    // 复位事件
    resetMap() {
      location.reload();
      // this.map.setCenter([115.464523, 38.874476]);
    },

    // 几何查询函数系列start
    opengeometryBox() {
      this.geometryBox = !this.geometryBox;
    },
    closegeometryBox() {
      this.geometryBox = !this.geometryBox;
    },
    // 集合查询函数系列start

    drawGeometry() {
      // if (this.geometrySearchType === "Rectangle") {

      if (!this.geometrySearchType) {
        this.$message({
          message: "请先选择几何元素类型再开始绘制",
          type: "warning",
        });
      }

      console.log(this.geometrySearchType);
      switch (this.geometrySearchType) {
        case "polygon": {
          this.mouseTool.polygon({
            fillColor: "#00b0ff",
            strokeColor: "#80d8ff",
            //同Polygon的Option设置
          });
          break;
        }
        case "rectangle": {
          this.mouseTool.rectangle({
            fillColor: "#00b0ff",
            strokeColor: "#80d8ff",
            //同Polygon的Option设置
          });
          break;
        }
        case "circle": {
          this.mouseTool.circle({
            fillColor: "#00b0ff",
            strokeColor: "#80d8ff",
            //同Circle的Option设置
          });
          break;
        }
      }
      // this.mouseTool.close(); //关闭，并清除覆盖物
      this.mouseTool.on("draw", (e) => {
        this.overlays.push(e.obj);
        // console.log("e.obj---------", e.obj.contains([115.638353, 39.004825]));

        // 遍历点位，判断是否在范围内
        for (let i = 0; i < this.dataList.length; i++) {
          if (e.obj.contains(this.dataList[i].coordinate)) {
            if (
              !this.geometrySearchRes.some(
                (ele) => ele.name === this.dataList[i].name
              )
            ) {
              this.geometrySearchRes.push(this.dataList[i]);
            }
          }
        }
        // console.log("几何查询结果geometrySearchRes", this.geometrySearchRes);
        this.mouseTool.close(); //关闭
        this.geometrySearchType = null;
      }); //解除绑定，
    },

    clearDrawGeometry() {
      this.mouseTool.close(true);
      this.geometrySearchRes = [];
    },
    closeDraw() {
      this.mouseTool.close(true);
      this.geometryBox = false;

      this.geometrySearchRes = [];
    },

    changeissearchRes() {
      this.issearchRes = !this.issearchRes;
    },

    // 查询结果跳转详情
    lookthis(row) {
      console.log(row);
      // this.$router.push({
      //   name: `industryMain`,
      //   params: { heritage: row._id },
      // });
      this.$router.push("/heritage/industry/main/" + row.row._id);
    },

    // 类型查询start
    async getAllType() {
      // var res = await this.$axios.get(
      //   "/getHeritageMainData/getHeritageMainData"
      // );
      // res = res.data.data;
      // console.log("请求结果", res);
      // this.dataList = res.data.data;
      // console.log(this.dataList);

      for (let i = 0; i < this.dataList.length; i++) {
        if (!this.options.some((ele) => ele.type === this.dataList[i].name)) {
          this.options.push(this.dataList[i]);
        }
      }
      console.log(this.options);
    },

    searchTypeClick() {
      console.log(this.typeSelect);
      this.map.remove(this.markers);
      this.map.clearInfoWindow();
      if (this.typeSelect === "test") {
        this.addMarker();
      } else {
        var filEnd = this.dataList.filter(
          (ele) => ele.name === this.typeSelect
        );
        console.log(filEnd);
        // this.map.clearMap();
        for (let i = 0; i < filEnd.length; i++) {
          // 循环点坐标
          // 注意这里一定得用 let
          let marker = new AMap.Marker({
            map: this.map,
            position: filEnd[i].coordinate,
            extData: filEnd[i],
          });

          this.map.setCenter(filEnd[i].coordinate); //设置地图中心点为当前位置

          this.markers.push(marker);

          AMap.event.addListener(marker, "click", () => {
            // this.nowMarker = marker;

            // console.log(this.infoWindow);
            this.title = filEnd[i].name;

            (this.content = [
              "开放日期：" + filEnd[i].start,

              "开放时间：" + filEnd[i].prolevel,
              "票价：" + filEnd[i].company,
              "故居简介：" + filEnd[i].brief,
            ]),
              (this.infoWindow = new AMap.InfoWindow({
                isCustom: true, //使用自定义窗体
                // content: '  <div style="background-color:white">111</div>',
                content: this.createInfoWindow(
                  this.title,
                  this.content.join("<br/>")
                ),
                offset: new AMap.Pixel(16, -45),
              }));
            this.infoWindow.open(this.map, marker.getPosition());

            // console.log(marker.getPosition());
          });
        }
        // this.map.setFitView();
        // AMap.event.addDomListener(
        //   document.getElementById("selectBtn"),
        //   "click",
        //   () => {
        //     this.map.setFitView();
        //   }
        // );
      }
    },
    // 类型查询end
  },
};
</script>

<style>
.heritage-industry #container {
  border-bottom: 1px solid #f9d5a7;
}
/* 弹框样式 */
.content-window-card {
  position: relative;
  box-shadow: none;
  bottom: 0;
  left: 0;
  width: auto;
  padding: 0;
}

.content-window-card p {
  height: 2rem;
}

.custom-info {
  border: solid 1px silver;
  width: 280px;
  background-color: white;
}

div.info-top {
  position: relative;
  background: none repeat scroll 0 0 #f9f9f9;
  border-bottom: 1px solid #ccc;
  border-radius: 5px 5px 0 0;
}

div.info-top div {
  display: inline-block;
  color: #333333;
  font-size: 14px;
  font-weight: bold;
  line-height: 31px;
  padding: 0 10px;
}

div.info-top img {
  position: absolute;
  top: 10px;
  right: 10px;
  transition-duration: 0.25s;
}

div.info-middle {
  font-size: 12px;
  padding: 10px 6px;
  line-height: 20px;
}
div.info-middle img {
  width: 100px;
  height: 70px;
  padding-bottom: 10px;
}

div.info-bottom {
  height: 0px;
  width: 100%;
  clear: both;
  text-align: center;
}

div.info-bottom img {
  position: relative;
  z-index: 104;
}

span {
  margin-left: 5px;
  font-size: 11px;
}

.info-middle img {
  float: left;
  margin-right: 6px;
}

.xiangxi {
  color: #555;
}

/* 地图元件样式 */

.heritage-industry .map-buttons {
  padding: 15px;
  z-index: 999;
  position: absolute;
  top: 0;
  right: 0;
}

.heritage-industry .geometrySearch {
  position: absolute;
  top: 60px;
  right: 0;
  z-index: 999;
  background-color: white;
  padding: 15px;
  border-radius: 5px;
  margin-right: 15px;
  border: 1px solid #dcdfe6;
}

.heritage-industry .geometrySearch .geometryType {
  display: block;
  padding-bottom: 15px;
  color: #606266;
}
.heritage-industry .geometrySearch .geometryBtns {
  padding-top: 15px;
}

.heritage-industry .map-buttons .closegeometryBox {
  margin-left: 0;
}

.heritage-industry .geometrySearch .searchRes {
  padding-top: 15px;
}

.heritage-industry .geometrySearch .searchRes .el-form-item__label {
  font-size: 12px;
  color: #111;
}
.heritage-industry .geometrySearch .searchRes .el-form-item {
  margin: 0;
  padding-left: 10px;
}
.heritage-industry .map-buttons .el-input__inner {
  border-top-right-radius: 0px;
  border-bottom-right-radius: 0px;
  border-right: none;
}
.heritage-industry .map-buttons .selectBtn {
  border-top-left-radius: 0px;
  border-bottom-left-radius: 0px;
  margin-right: 10px;
}
</style>
